<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the status for the running task</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmanclient.donormal.html">GearmanClient::doNormal</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanclient.echo.html">GearmanClient::echo</a></div>
 <div class="up"><a href="class.gearmanclient.html">GearmanClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="gearmanclient.dostatus" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">GearmanClient::doStatus</h1>
  <p class="verinfo">(PECL gearman &gt;= 0.5.0)</p><p class="refpurpose"><span class="refname">GearmanClient::doStatus</span> &mdash; <span class="dc-title">Get the status for the running task</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-gearmanclient.dostatus-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>GearmanClient::doStatus</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Returns the status for the running task.  This should be used between repeated
   <span class="methodname"><a href="gearmanclient.donormal.html" class="methodname">GearmanClient::doNormal()</a></span> calls.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-gearmanclient.dostatus-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-gearmanclient.dostatus-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   An array representing the percentage completion given as a fraction, with the
   first element the numerator and the second element the denomintor.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-gearmanclient.dostatus-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4233">
    <p><strong>Example #1 Get the status of a long running job</strong></p>
    <div class="example-contents"><p>
     The worker in this example has an artificial delay added during processing of the
     string to be reversed.  After each delay it calls <span class="methodname"><a href="gearmanjob.status.html" class="methodname">GearmanJob::status()</a></span>
     which the client then picks up.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Starting\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">#&nbsp;Create&nbsp;our&nbsp;client&nbsp;object.<br /></span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">GearmanClient</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">#&nbsp;Add&nbsp;default&nbsp;server&nbsp;(localhost).<br /></span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">();<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Sending&nbsp;job\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">#&nbsp;Send&nbsp;reverse&nbsp;job<br /></span><span style="color: #007700">do<br />{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">doNormal</span><span style="color: #007700">(</span><span style="color: #DD0000">"reverse"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Hello!"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">#&nbsp;Check&nbsp;for&nbsp;various&nbsp;return&nbsp;packets&nbsp;and&nbsp;errors.<br />&nbsp;&nbsp;</span><span style="color: #007700">switch(</span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">returnCode</span><span style="color: #007700">())<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">GEARMAN_WORK_DATA</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">GEARMAN_WORK_STATUS</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#&nbsp;get&nbsp;the&nbsp;current&nbsp;job&nbsp;status<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">list(</span><span style="color: #0000BB">$numerator</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$denominator</span><span style="color: #007700">)=&nbsp;</span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">doStatus</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Status:&nbsp;</span><span style="color: #0000BB">$numerator</span><span style="color: #DD0000">/</span><span style="color: #0000BB">$denominator</span><span style="color: #DD0000">&nbsp;complete\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">GEARMAN_WORK_FAIL</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Failed\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">GEARMAN_SUCCESS</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;default:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"RET:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">returnCode</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;}<br />}<br />while(</span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">returnCode</span><span style="color: #007700">()&nbsp;!=&nbsp;</span><span style="color: #0000BB">GEARMAN_SUCCESS</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Success:&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Starting
Sending job
Status: 1/6 complete
Status: 2/6 complete
Status: 3/6 complete
Status: 4/6 complete
Status: 5/6 complete
Status: 6/6 complete
Success: !olleH
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-gearmanclient.dostatus-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="gearmanclient.donormal.html" class="methodname" rel="rdfs-seeAlso">GearmanClient::doNormal()</a> - Run a single task and return a result</span></li>
    <li class="member"><span class="methodname"><a href="gearmanjob.status.html" class="methodname" rel="rdfs-seeAlso">GearmanJob::status()</a> - Send status (deprecated)</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmanclient.donormal.html">GearmanClient::doNormal</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanclient.echo.html">GearmanClient::echo</a></div>
 <div class="up"><a href="class.gearmanclient.html">GearmanClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
